<%!

  Copyright (c) Facebook, Inc. and its affiliates.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

%>class <%service:name%>AsyncProcessor : public <%#service:extends%><% > common/namespace_cpp2%><%service:name%>AsyncProcessor<%/service:extends%><%^service:extends%>::apache::thrift::GeneratedAsyncProcessor<%/service:extends%> {
 public:
  const char* getServiceName() override;
  void getServiceMetadata(apache::thrift::metadata::ThriftServiceMetadataResponse& response) override;
<%#service:extends%>
  using BaseAsyncProcessor = <% > common/namespace_cpp2%><%service:name%>AsyncProcessor;
<%/service:extends%>
<%^service:extends%>
  using BaseAsyncProcessor = void;
<%/service:extends%>
 protected:
  <%service:name%>SvIf* iface_;
 public:
  void processSerializedRequest(apache::thrift::ResponseChannelRequest::UniquePtr req, apache::thrift::SerializedRequest&& serializedRequest, apache::thrift::protocol::PROTOCOL_TYPES protType, apache::thrift::Cpp2RequestContext* context, folly::EventBase* eb, apache::thrift::concurrency::ThreadManager* tm) override;
 protected:
  std::shared_ptr<folly::RequestContext> getBaseContextForRequest() override;
 public:
  using ProcessFunc = GeneratedAsyncProcessor::ProcessFunc<<%service:name%>AsyncProcessor>;
  using ProcessMap = GeneratedAsyncProcessor::ProcessMap<ProcessFunc>;
  static const <%service:name%>AsyncProcessor::ProcessMap& getBinaryProtocolProcessMap();
  static const <%service:name%>AsyncProcessor::ProcessMap& getCompactProtocolProcessMap();
 private:
  static const <%service:name%>AsyncProcessor::ProcessMap binaryProcessMap_;
   static const <%service:name%>AsyncProcessor::ProcessMap compactProcessMap_;
 private:
<%#service:functions%><%#function:returnType%>
<%^function:eb%>
  template <typename ProtocolIn_, typename ProtocolOut_>
  void _processInThread_<%function:cpp_name%>(apache::thrift::ResponseChannelRequest::UniquePtr req, apache::thrift::SerializedRequest&& serializedRequest, apache::thrift::Cpp2RequestContext* ctx, folly::EventBase* eb, apache::thrift::concurrency::ThreadManager* tm);
<%/function:eb%>
  template <typename ProtocolIn_, typename ProtocolOut_>
  void process_<%function:cpp_name%>(apache::thrift::ResponseChannelRequest::UniquePtr req, apache::thrift::SerializedRequest&& serializedRequest, apache::thrift::Cpp2RequestContext* ctx,folly::EventBase* eb, apache::thrift::concurrency::ThreadManager* tm);
<%^function:oneway?%>
  template <class ProtocolIn_, class ProtocolOut_>
<%#type:void?%>
  static folly::IOBufQueue return_<%function:cpp_name%>(int32_t protoSeqId, apache::thrift::ContextStack* ctx);
<%/type:void?%>
<%^type:void?%>
  <%^type:streamresponse?%><%^type:sink?%>
  static folly::IOBufQueue return_<%function:cpp_name%>(int32_t protoSeqId, apache::thrift::ContextStack* ctx, <% > types/type%> const& _return);
  <%/type:sink?%><%/type:streamresponse?%>
  <%#type:streamresponse?%>
  static apache::thrift::ResponseAndServerStreamFactory return_<%function:cpp_name%>(int32_t protoSeqId, apache::thrift::ContextStack* ctx, folly::Executor::KeepAlive<> executor, <% > types/type%> _return);
  <%/type:streamresponse?%>
  <%#type:sink?%>
  static std::pair<folly::IOBufQueue, apache::thrift::detail::SinkConsumerImpl> return_<%function:cpp_name%>(apache::thrift::ContextStack* ctx, <% > types/type%>&& _return, folly::Executor::KeepAlive<> executor);
  <%/type:sink?%>
<%/type:void?%>
  template <class ProtocolIn_, class ProtocolOut_>
  static void throw_wrapped_<%function:cpp_name%>(apache::thrift::ResponseChannelRequest::UniquePtr req,int32_t protoSeqId,apache::thrift::ContextStack* ctx,folly::exception_wrapper ew,apache::thrift::Cpp2RequestContext* reqCtx);
<%/function:oneway?%>
<%/function:returnType%><%/service:functions%>
 public:
  <%service:name%>AsyncProcessor(<%service:name%>SvIf* iface) :
<%#service:extends%>
      <% > common/namespace_cpp2%><%service:name%>AsyncProcessor(iface),
<%/service:extends%>
      iface_(iface) {}

  virtual ~<%service:name%>AsyncProcessor() {}
};
